
import 'dart:ffi';

import 'package:flutter/services.dart';

import 'stripe_terminal_tap_to_pay_platform_interface.dart';

class StripeTerminalTapToPay {
  var methodChannel =  const MethodChannel('stripe_terminal_tap_to_pay');
  Function? onErrorLogCallBack;
  Function? onSuccessNFCBack;
  Function? onPayMessageBack;


  StripeTerminalTapToPay(){
    methodChannel.setMethodCallHandler((call) async {
      switch (call.method) {
        case "onErrorLog":
          await onErrorLogCallBack!(call.arguments);
          break;
        case "onSuccessNFC":
          await onSuccessNFCBack!(call.arguments);
          break;
        case "onPayMessage":
          await onPayMessageBack!(call.arguments);
          break;
      }
    });
  }


  Future<String?> getPlatformVersion() {
    return StripeTerminalTapToPayPlatform.instance.getPlatformVersion();
  }


  Future<void> init(String localId,String result) async {
    await StripeTerminalTapToPayPlatform.instance.init(localId,result);
  }
  Future<Map> pay(String clientSecret) async {
    return StripeTerminalTapToPayPlatform.instance.pay(clientSecret);
  }

  Future<bool> permissionAllowed() async{
    return StripeTerminalTapToPayPlatform.instance.permissionAllowed();
  }

  Future<bool> cancelRetrievePaymentIntent() async {
    return StripeTerminalTapToPayPlatform.instance.cancelRetrievePaymentIntent();
  }

  Future<void> cancelProcessPayment() async {
    await StripeTerminalTapToPayPlatform.instance.cancelProcessPayment();
  }
}
